# Project: dcto8d PANDORA

DCTO8DPND_VERSION = 0.5.0

ifeq ($(MAKECMDGOALS),dcto8d_host)
  TARGET = dcto8dpnd_host
  OBJFOLDER = objects_host
  CFLAGS += -march=native -I/usr/include/SDL -DPND_MODE -DNO_FULLSCREEN -O3
  CFLAGS += -falign-functions=32 -falign-loops -falign-labels -falign-jumps -fomit-frame-pointer -ffast-math
else
  TARGET = dcto8dpnd.bin
  OBJFOLDER = objects
  CFLAGS += -I/usr/include/SDL -DPND_MODE -O2 --sysroot=/usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/
  CFLAGS += -falign-functions=32 -falign-loops -falign-labels -falign-jumps -fomit-frame-pointer -ffast-math
  CFLAGS += -frename-registers -fexpensive-optimizations -finline -finline-functions
endif

objects = $(OBJFOLDER)/dcto8dmain.o $(OBJFOLDER)/dc6809emul.o \
	$(OBJFOLDER)/dcto8dinterface.o $(OBJFOLDER)/dcto8ddevices.o $(OBJFOLDER)/dcto8demulation.o \
	$(OBJFOLDER)/dcto8dkeyb.o $(OBJFOLDER)/dcto8doptions.o $(OBJFOLDER)/dcto8dvideo16.o \
	$(OBJFOLDER)/dc6809dass.o $(OBJFOLDER)/dcto8ddesass.o

dcto8d_host: $(objects)
	$(CC) -o $(TARGET) -lSDL -lSDL_ttf $(objects)

$(TARGET) : $(objects)
	$(CC) -o $(TARGET) -lSDL -lSDL_ttf $(objects)

$(OBJFOLDER)/dcto8dmain.o : source/dcto8dmain.c
	$(CC) -c source/dcto8dmain.c -o $(OBJFOLDER)/dcto8dmain.o -O2 $(CFLAGS)

$(OBJFOLDER)/dc6809emul.o : source/dc6809emul.c
	$(CC) -c source/dc6809emul.c -o $(OBJFOLDER)/dc6809emul.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8dinterface.o : source/dcto8dinterface.c
	$(CC) -c source/dcto8dinterface.c -o $(OBJFOLDER)/dcto8dinterface.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8ddevices.o : source/dcto8ddevices.c
	$(CC) -c source/dcto8ddevices.c -o $(OBJFOLDER)/dcto8ddevices.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8demulation.o : source/dcto8demulation.c
	$(CC) -c source/dcto8demulation.c -o $(OBJFOLDER)/dcto8demulation.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8dkeyb.o : source/dcto8dkeyb.c source/dcto8dkeyb.h
	$(CC) -c source/dcto8dkeyb.c -o $(OBJFOLDER)/dcto8dkeyb.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8doptions.o : source/dcto8doptions.c
	$(CC) -c source/dcto8doptions.c -o $(OBJFOLDER)/dcto8doptions.o -O2 $(CFLAGS)

$(OBJFOLDER)/dcto8dvideo16.o : source/dcto8dvideo16.c
	$(CC) -c source/dcto8dvideo16.c -o $(OBJFOLDER)/dcto8dvideo16.o -O2 $(CFLAGS)

$(OBJFOLDER)/dc6809dass.o: source/dc6809dass.c source/dc6809dass.h
	$(CC) -c source/dc6809dass.c -o $(OBJFOLDER)/dc6809dass.o $(CFLAGS)

$(OBJFOLDER)/dcto8ddesass.o: source/dcto8ddesass.c
	$(CC) -c source/dcto8ddesass.c -o $(OBJFOLDER)/dcto8ddesass.o -O2 $(CFLAGS)

install: $(TARGET)
	cp $(TARGET) build/. && (pnd_make -c -p dcto8dpnd-$(DCTO8DPND_VERSION).pnd -d build -i build/to8_ico.png -x build/PXML.xml)

clean :
	rm -f $(TARGET) objects/* objects_host/*

all: $(TARGET)
